package br.com.tonaaula;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class DisciplinaDAO {

	private DatabaseHelper helper;
	
	public DisciplinaDAO(DatabaseHelper helper) {
		this.helper = helper;
	}
	
	
	public void salvar(String v) {
		SQLiteDatabase  db =  helper.getWritableDatabase();
		ContentValues values = new ContentValues();
		
		values.put("nome", v);
		
		db.insert("disciplina", null, values);
		
		db.close();
	}
	
	public List<Map<String,Object>> listar() {
		SQLiteDatabase  db =  helper.getReadableDatabase();
		//db.rawQuery("select _id, nome from disciplina where _id = ? ", new String[]{ "dsds"});
		Cursor cursor = db.rawQuery("select _id, nome from disciplina ",null);
		
		cursor.moveToFirst();
		
		List<Map<String,Object>> lista = new ArrayList<Map<String,Object>>();
		
		for(int i = 0; i < cursor.getCount();i++){
			Map<String,Object> item = new HashMap<String, Object>();
			int id = cursor.getInt(0);
			item.put("imagem", android.R.drawable.ic_dialog_info);
			item.put("data", cursor.getString(0));
			item.put("hora", cursor.getString(1));
			item.put("valor", cursor.getString(1));
			lista.add(item);
			cursor.moveToNext();
			
		}
		cursor.close();
		
		return lista;
		
	}
	
	
	
	
}
